package org.example.struct.array;

import com.alibaba.fastjson.JSON;

/**
 * @author liyishan
 * @date 2023/8/9 11:31
 * @apiNote
 */

public class Test00867Transpose {
    public static void main(String[] args) {
        int[][]  matrix = new int[][]{{1,2,3},{4,5,6},{7,8,9}};
        int[][] result = test(matrix);
        System.out.println(JSON.toJSON(result));
    }

    public static int[][] test(int[][] matrix){
        int m = matrix.length;
        int n = matrix[0].length;
        int[][] result = new int[n][m];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                result[j][i] = matrix[i][j];
            }
        }
        return result;
    }
}
